Page({
  data: {
    form: {
      avatar: '/assets/images/doctor-avatar.jpg',
      name: '示例医生',
      title: '主治医师',
      department: '营养科',
      specialty: '慢病管理、减重指导',
      bio: '十年临床与营养管理经验。'
    }
  },
  onInput(e) {
    const field = e.currentTarget.dataset.field;
    const value = e.detail.value;
    this.setData({ [`form.${field}`]: value });
  },
  save() {
    wx.showToast({ title: '已保存', icon: 'success' });
  },
  logout() {
    try {
      wx.clearStorageSync();
    } catch (e) {}
    try { wx.showToast({ title: '已退出', icon: 'success', duration: 1000 }); } catch (e) {}
    setTimeout(() => {
      // 退出后回到登录
      wx.reLaunch({ url: '/pages/login/login' });
    }, 800);
  }
});

